﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="VerwijderBericht.aspx.cs" Inherits="Quaack.VerwijderBericht" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">

     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="messages" OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand" DataKeyNames="messid">
            <Columns>
               
                 <asp:TemplateField HeaderText="messid" InsertVisible="False" SortExpression="messid">
                     <EditItemTemplate>
                         <asp:Label ID="Label1" runat="server"  Text='<%# Eval("messid") %>'></asp:Label>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label1" runat="server"  Text='<%# Bind("messid") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="sender" SortExpression="sender">
                     <EditItemTemplate>
                         <asp:TextBox ID="TextBox1" runat="server" ReadOnly="true" Text='<%# Bind("sender") %>'></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label2" runat="server"  Text='<%# Bind("sender") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="parentmessid" SortExpression="parentmessid">
                     <EditItemTemplate>
                         <asp:TextBox ReadOnly="true" ID="TextBox2" runat="server"  Text='<%# Bind("parentmessid") %>'></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label3" runat="server"  Text='<%# Bind("parentmessid") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:CheckBoxField DataField="removed" HeaderText="removed" SortExpression="removed" />


                 <asp:TemplateField HeaderText="message" SortExpression="message">
                     <EditItemTemplate>
                         <asp:TextBox ReadOnly="true" ID="TextBox3" runat="server" Text='<%# Bind("message") %>'></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label4" runat="server"  Text='<%# Bind("message") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="username" SortExpression="username">
                     <EditItemTemplate>
                         <asp:TextBox ReadOnly="true" ID="TextBox4" runat="server"  Text='<%# Bind("username") %>'></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label5" runat="server"  Text='<%# Bind("username") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:ButtonField CommandName="Verwijder" Text="Verwijder" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="messages" runat="server" ConnectionString="<%$ ConnectionStrings:Quaack %>" SelectCommand="SELECT message.messid, message.sender, message.parentmessid, message.removed, message.message, profile.username FROM message INNER JOIN profile ON message.sender = profile.profileid INNER JOIN profile AS profile_1 ON message.sender = profile_1.profileid WHERE (message.sender = @sender) OR (message.parentmessid = @sender)" DeleteCommand="DELETE FROM [message] WHERE [messid] = @messid" InsertCommand="INSERT INTO [message] ([sender], [parentmessid], [removed], [message]) VALUES (@sender, @parentmessid, @removed, @message)" UpdateCommand="UPDATE [message] SET [sender] = @sender, [parentmessid] = @parentmessid, [removed] = @removed, [message] = @message WHERE [messid] = @messid">
            <DeleteParameters>
                <asp:Parameter Name="messid" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="sender" Type="Int32"  />
                <asp:Parameter Name="parentmessid" Type="Int32" />
                <asp:Parameter Name="removed" Type="Boolean" />
                <asp:Parameter Name="message" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:SessionParameter DefaultValue="0" Name="sender" SessionField="userID" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="sender" Type="Int32"  />
                <asp:Parameter Name="parentmessid" Type="Int32" />
                <asp:Parameter Name="removed" Type="Boolean" />
                <asp:Parameter Name="message" Type="String" />
                <asp:Parameter Name="messid" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
   
    <p>
        &nbsp;</p>
</asp:Content>
